<?php
/** 
 * 
 *
 * @package api
 * @subpackage lang
 * @author Richard Fullmer <php-api@byu.edu>
 * @version 1.0
 */
/**
 *
 */
require_once( "lang/Object.php" );
/**
 * Class Aarray
 *
 * The class Aarray wraps a PHP array literal.  
 *
 * It allows for the getting and setting of key/value pairs within the array.  If you wish to use store PHP arrays in any type of 
 * collection, you must use this class to wrap them as collections only accept objects that extend the base Object class.
 *
 * @package api
 * @subpackage lang
 */
class Aarray extends Object {
	private $arr;
	
	public function __construct( $arr ) {
		$this->arr = $arr;
	}
	
	public function get( $index ) {
		// throw expection here if out of bounds
		
		return $this->arr[$index];
	}
	
	public function set( $index, $value ) {
		// throw expection here if out of bounds
		$old_value = $this->arr[$index];
		$this->arr[$index] = $value;
		return $old_value;
	}
	
	public function toString() {
		$str = "Array ( ";
		foreach ($this->arr as $key => $value ) {
			$str .= "[$key] => $value ";
		}	
		$str .= " )";
		return $str;
	}
}

?>